<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>个人信息</title>
  <script type="text/javascript" src="<%=request.getContextPath() %>/common/jquery-1.8.2.min.js"></script>
<jsp:include page="/common/easyui.jsp"></jsp:include>

<script type="text/javascript">
	$.extend($.fn.validatebox.defaults.rules, {    
	    equals: {    
	        validator: function(value,param){    
	            return value == $(param[0]).val();    
	        },    
	        message: '两次密码输入不一致.'   
	    }    
	});  

	$(function(){
	
		$.ajax({
			type:"post",
			url:"<%=request.getContextPath()%>/user/loadPersonInfo.do",
			dataType:"json",
			success:function(obj){
				$('#ff').form('load',{
					id:obj.id,
					loginname:obj.loginname,
					mail:obj.mail,
					realname:obj.realname,
					phone:obj.phone,
					password:obj.password,
					rpwd:obj.password,
					sex:obj.sex,
					age:obj.age,
					typeid:loadType(obj.userType),
					classid:loadClazz(obj.clazz),
				});
			}
		})
	});
	function loadType(type){
		if(type!=null){
			return type.id;
		}
	}
	
	function loadClazz(clazz){
		if(clazz!=null){
			return clazz.id;
		}
	}
	
</script>
</head>
<body>
		<div id="dd" class="easyui-dialog" title="My Dialog"
		style="width:950px;height:450px;"
		data-options="iconCls:'icon-save',resizable:true,modal:true,buttons:[{
				text:'保存',
				handler:function(){
					$.ajax({
						type:'post',
						url:'<%=request.getContextPath() %>/user/upPersonInfo.do',
						data:$('#ff').serialize(),
						success:function(msg){
								$.messager.confirm('修改OK','是否重新登录？',function(r){    
								    if (r){    
								        window.top.location.href='<%=request.getContextPath() %>/user/outLogin.do' 
								    }else{
								    	$('#dd').dialog({
											closed:true
										})
								    }    
								}); 
								
								
													
						}
					})
				 }
			},{
				text:'关闭',
				handler:function(){ $('#dd').dialog({
					closed:true
				})}
			}]">
			<center>
			
		<form id="ff" method="post">
			<input type="hidden" name="id">
			<table cellpadding="15" cellspacing="0">
				<tr>
					<td>用户名:</td>
					<td><input class="easyui-validatebox" type="text"
						name="loginname" data-options="required:true" /></td>
				</tr>
				<tr>
					<td>密码:</td>
					<td><input id="pwd" class="easyui-validatebox" type="password"
						name="password" data-options="required:true" />
					</td>
				</tr>
				<tr>
					<td>确认密码：</td>
					<td><input id="rpwd" name="rpwd" type="password" class="easyui-validatebox"  required="required" validType="equals['#pwd']" />  
    			</td>
				<tr>
					<td>真实姓名:</td>
					<td><input class="easyui-validatebox" type="text"
						name="realname" data-options="required:true" />
					</td>
				<tr>
					<td>联系方式:</td>
					<td><input class="easyui-validatebox" type="text" name="phone"
						data-options="required:true" />
					</td>
				<tr>
					<td>邮箱:</td>
					<td><input class="easyui-validatebox" type="text" name="mail"
						data-options="validType:'email',required:true" />
					</td>
				</tr>
				<tr>
					<td>年龄:</td>
					<td><input class="easyui-numberbox" type="text" name="age"
						data-options="min:16,max:65" />
					</td>
				</tr>
				<tr>
					<td>性别:</td>
					<td><input class="easyui-validatebox" type="radio" value="1"
						name="sex" data-options="required:true" /> 男 <input
						class="easyui-validatebox" type="radio" value="0" name="sex"
						data-options="required:true" /> 女</td>
				</tr>
					<tr><td>
				班级：
				</td><td>
					<input id="cc" class="easyui-combobox" name="classid"   
 							  data-options="valueField:'id',textField:'name',url:'<%=request.getContextPath() %>/user/getClasses.do'" />  
				</td></tr>
				<tr><td>
				班级：
				</td><td>
					<input id="cc" class="easyui-combobox" name="typeid"   
 							  data-options="valueField:'id',textField:'name',url:'<%=request.getContextPath() %>/user/getTypes.do'" />  
				</td></tr>
				
			</table>
		</form>
		</center>
	</div>
</body>
</html>